//
//  SLOtherProductComponent.m
//  SulitLoanDemo
//
//  Created by 虞嘉伟 on 2025/2/19.
//  
  

#import "SLOtherProductComponent.h"
#import <YYKit.h>
#import <Masonry.h>


@implementation SLOtherProductComponent

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self addSubview:self.otherButton];
        [self.otherButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(self);
            make.height.mas_equalTo(30);
            make.width.mas_equalTo(self.otherButton.intrinsicContentSize.width+40);
        }];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.otherButton.layer.cornerRadius = CGRectGetHeight(self.otherButton.bounds)*0.5;
}

- (void)otherButtonAction:(UIButton *)button {
    !self.otherButtonCallback ?: self.otherButtonCallback();
}

- (UIButton *)otherButton {
    if (!_otherButton) {
        _otherButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_otherButton setTitle:@"Other products" forState:UIControlStateNormal];
        _otherButton.titleLabel.font = aspectDefaultFont(16);
        _otherButton.backgroundColor = UIColorHex(#1B1B1B);
        [_otherButton addTarget:self action:@selector(otherButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _otherButton;
}
@end
